home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume16 / less5 / part04 < prev    next >
Encoding:
Internet Message Format  |  1988-09-22  |  58.0 KB

  1. Subject:  v16i033:  Less, a pager that's more than more, Part04/04
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: ctnews!UNIX386!mark
  7. Posting-number: Volume 16, Issue 33
  8. Archive-name: less5/part04
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.
  12. # Remove anything before this line, then unpack it
  13. # by saving it into a file and typing "sh file".
  14.  
  15. echo shar: Extracting \"linstall\"
  16. sed "s/^X//" >'linstall' <<'END_OF_FILE'
  17. X#! /bin/sh
  18. X# Installation script for less.
  19. X# This script prompts the operator for various information
  20. X# and constructs a makefile.
  21. X
  22. Xecho "This script will build a makefile for less."
  23. Xecho "If you already have a file called \"makefile\" it will be overwritten."
  24. Xecho "Press RETURN to continue."
  25. Xread ans
  26. X
  27. Xecho "I will ask you some questions about your system."
  28. Xecho "If you do not know the answer to any question,"
  29. Xecho "just press RETURN and I will choose a default for you."
  30. Xecho "Press RETURN now."
  31. Xread ans
  32. X
  33. XECHO=./vecho
  34. Xif [ ! -x $ECHO ]
  35. Xthen
  36. X    echo "One moment..."
  37. X    cc -o $ECHO vecho.c
  38. X    echo ""
  39. Xfi
  40. X
  41. X$ECHO "Most Unix systems are derived from either System V"
  42. X$ECHO "or Berkeley BSD 4.1, 4.2, 4.3, etc."
  43. X$ECHO ""
  44. X$ECHO "Is your system closest to:"
  45. X$ECHO "  1. System V"
  46. X$ECHO "  2. BSD 4.1"
  47. X$ECHO "  3. BSD 4.2 or later"
  48. X$ECHO "  4. Xenix"
  49. X$ECHO "Enter a number, or just RETURN if you don't know: \c"
  50. Xread ans
  51. Xxenix=0
  52. Xcase "X$ans" in
  53. XX1) sys=sys5; sysname="System V" ;;
  54. XX2) sys=bsd; bsd41=1; sysname="BSD 4.1" ;;
  55. XX3) sys=bsd; bsd41=0; sysname="BSD 4.2" ;;
  56. XX4) sys=sys5; xenix=1; sysname="Xenix" ;;
  57. X*) sys=unknown ;;
  58. Xesac
  59. X$ECHO ""
  60. X
  61. XDATE=`date`
  62. Xcat >makefile <<EOF
  63. X# Makefile for "less"
  64. X# Generated $DATE by $0.
  65. XEOF
  66. X
  67. Xcat >>makefile <<"EOF"
  68. X#
  69. X# Invoked as:
  70. X#    make all
  71. X#   or    make install
  72. X# Plain "make" is equivalent to "make all".
  73. X#
  74. X# If you add or delete functions, remake funcs.h by doing:
  75. X#    make newfuncs
  76. X# This depends on the coding convention of function headers looking like:
  77. X#    " \t public <function-type> \n <function-name> ( ... ) "
  78. X#
  79. X# Also provided:
  80. X#    make lint    # Runs "lint" on all the sources.
  81. X#    make clean    # Removes "less" and the .o files.
  82. X#    make clobber    # Pretty much the same as make "clean".
  83. X
  84. XSHELL = /bin/sh
  85. X
  86. XEOF
  87. X
  88. Xcat >defines.h <<EOF
  89. X/* Definition file for less */
  90. X/* Generated $DATE by $0. */
  91. X
  92. XEOF
  93. X
  94. Xcat >>defines.h <<EOF
  95. X/*
  96. X * Define XENIX if running under XENIX 3.0.
  97. X */
  98. X#define    XENIX        $xenix
  99. X
  100. XEOF
  101. X$ECHO ""
  102. X
  103. X
  104. X
  105. Xif [ "X$sys" = "Xunknown" ]
  106. Xthen
  107. X    alldefault=0
  108. Xelse
  109. X    def=yes
  110. X    alldefault=1
  111. X    $ECHO "Do you want to use ALL the defaults for $sysname?"
  112. X    $ECHO "  Enter \"yes\" if you have a STANDARD $sysname."
  113. X    $ECHO "  Enter \"no\" if you want to change any of the defaults. [$def] \c"
  114. X    read ans
  115. X    case "X$ans" in
  116. X    X[yY]*) alldefault=1 ;;
  117. X    X[nN]*) alldefault=0 ;;
  118. X    esac
  119. X    $ECHO ""
  120. Xfi
  121. X
  122. Xif [ $alldefault = 0 ]
  123. Xthen
  124. X    alloptional=0
  125. Xelse
  126. X    def=yes
  127. X    alloptional=1
  128. X    $ECHO "Do you want to use all the optional features of less?"
  129. X    $ECHO "  Less has several features which you may or may not"
  130. X    $ECHO "  wish to include, such as shell escapes."
  131. X    $ECHO "  Enter \"yes\" if you want to include ALL the optional features."
  132. X    $ECHO "  Enter \"no\" if you want to select individual features. [$def] \c"
  133. X    read ans
  134. X    case "X$ans" in
  135. X    X[yY]*) alloptional=1 ;;
  136. X    X[nN]*) alloptional=0 ;;
  137. X    esac
  138. X    $ECHO ""
  139. Xfi
  140. X
  141. X
  142. X
  143. Xdef=yes
  144. Xx=1
  145. Xif [ $alldefault = 0 ]
  146. Xthen
  147. X    $ECHO "Does your C compiler support the \"void\" type? [$def] \c"
  148. X    read ans
  149. X    case "X$ans" in
  150. X    X[yY]*) x=1 ;;
  151. X    X[nN]*) x=0 ;;
  152. X    esac
  153. X    $ECHO ""
  154. Xfi
  155. Xcat >>defines.h <<EOF
  156. X/*
  157. X * VOID is 1 if your C compiler supports the "void" type,
  158. X * 0 if it does not.
  159. X */
  160. X#define    VOID        $x
  161. X
  162. XEOF
  163. X
  164. X
  165. X
  166. Xdef=long
  167. Xif [ $alldefault = 0 ]
  168. Xthen
  169. X    $ECHO "What type is the \"offset\" argument to lseek? [$def] \c"
  170. X    read ans
  171. X    if [ "X$ans" != "X" ]
  172. X    then
  173. X        def=$ans
  174. X    fi
  175. X    $ECHO ""
  176. Xfi
  177. Xcat >>defines.h <<EOF
  178. X/*
  179. X * offset_t is the type which lseek() returns.
  180. X * It is also the type of lseek()'s second argument.
  181. X */
  182. X#define    offset_t    $def
  183. X
  184. XEOF
  185. X
  186. X
  187. X
  188. X
  189. Xdef=yes; x=1
  190. Xif [ $alldefault = 0 ]
  191. Xthen
  192. X    $ECHO "Most Unix systems provide the stat() function."
  193. X    $ECHO "Does your system have stat()? [$def] \c"
  194. X    read ans
  195. X    case "X$ans" in
  196. X    X[yY]*) x=1 ;;
  197. X    X[nN]*) x=0 ;;
  198. X    esac
  199. X    $ECHO ""
  200. Xfi
  201. Xcat >>defines.h <<EOF
  202. X/*
  203. X * STAT is 1 if your system has the stat() call.
  204. X */
  205. X#define    STAT        $x
  206. X
  207. XEOF
  208. X
  209. X
  210. X
  211. X
  212. Xdef=yes; x=1
  213. Xif [ $alldefault = 0 ]
  214. Xthen
  215. X    $ECHO "Most Unix systems provide the perror() function."
  216. X    $ECHO "Does your system have perror()? [$def] \c"
  217. X    read ans
  218. X    case "X$ans" in
  219. X    X[yY]*) x=1 ;;
  220. X    X[nN]*) x=0 ;;
  221. X    esac
  222. X    $ECHO ""
  223. Xfi
  224. Xcat >>defines.h <<EOF
  225. X/*
  226. X * PERROR is 1 if your system has the perror() call.
  227. X * (Actually, if it has sys_errlist, sys_nerr and errno.)
  228. X */
  229. X#define    PERROR        $x
  230. X
  231. XEOF
  232. X
  233. X
  234. X
  235. X
  236. Xdef=yes; x=1
  237. Xif [ $alldefault = 0 ]
  238. Xthen
  239. X    $ECHO "Most Unix systems provide the time() function."
  240. X    $ECHO "Does your system have time()? [$def] \c"
  241. X    read ans
  242. X    case "X$ans" in
  243. X    X[yY]*) x=1 ;;
  244. X    X[nN]*) x=0 ;;
  245. X    esac
  246. X    $ECHO ""
  247. Xfi
  248. Xcat >>defines.h <<EOF
  249. X/*
  250. X * GET_TIME is 1 if your system has the time() call.
  251. X */
  252. X#define    GET_TIME    $x
  253. X
  254. XEOF
  255. X
  256. Xif [ $x = 0 ]
  257. Xthen
  258. X    $ECHO "What is the APPROXIMATE performance of your"
  259. X    $ECHO "machine, as a percentage of a Vax 11/750?"
  260. X    $ECHO "(Enter 100 if your machine is as fast as a Vax,"
  261. X    $ECHO " 50 if it is half as fast, 200 if it is twice as fast, etc.)"
  262. X    $ECHO "The accuracy of this information is not critical."
  263. X    while :
  264. X    do
  265. X        $ECHO "Percent of Vax 11/750 [100]: \c"
  266. X        read ans
  267. X        if [ "X$ans" = "X" ]
  268. X        then
  269. X            ans=100
  270. X        fi
  271. X        longloop=`expr "$ans" "*" 3`
  272. X        if [ $? = 0 ]
  273. X        then
  274. X            break
  275. X        fi
  276. X        $ECHO "Enter a number please!"
  277. X    done
  278. X    $ECHO ""
  279. X
  280. X    cat >>defines.h <<EOF
  281. X/*
  282. X * LONGLOOP is the number of lines we should process in the line number
  283. X * scan before displaying a warning that it will take a while.
  284. X */
  285. X#define    LONGLOOP    ($longloop)
  286. XEOF
  287. Xfi
  288. X
  289. X
  290. X
  291. X
  292. Xif [ "$sys" = "bsd" ]
  293. Xthen
  294. X    def=no; x=0
  295. Xelse
  296. X    def=yes; x=1
  297. Xfi
  298. Xif [ $alldefault = 0 ]
  299. Xthen
  300. X    $ECHO "Most System V systems have termio.h, while most"
  301. X    $ECHO "Berkeley-derived systems have sgtty.h."
  302. X    $ECHO "Does your system have termio.h? [$def] \c"
  303. X    read ans
  304. X    case "X$ans" in
  305. X    X[yY]*) x=1 ;;
  306. X    X[nN]*) x=0 ;;
  307. X    esac
  308. X    $ECHO ""
  309. Xfi
  310. Xcat >>defines.h <<EOF
  311. X/*
  312. X * TERMIO is 1 if your system has /usr/include/termio.h.
  313. X * This is normally the case for System 5.
  314. X * If TERMIO is 0 your system must have /usr/include/sgtty.h.
  315. X * This is normally the case for BSD.
  316. X */
  317. X#define    TERMIO        $x
  318. X
  319. XEOF
  320. X
  321. X
  322. X
  323. X
  324. Xif [ "$sys" = "bsd" -a "$bsd41" = "0" ]
  325. Xthen
  326. X    def=yes; x=1
  327. Xelse
  328. X    def=no; x=0
  329. Xfi
  330. Xif [ $alldefault = 0 ]
  331. Xthen
  332. X    $ECHO "Most BSD 4.2 and 4.3 systems have the sigsetmask() call."
  333. X    $ECHO "Most System V and BSD 4.1 systems do not."
  334. X    $ECHO "Does your system have sigsetmask()? [$def] \c"
  335. X    read ans
  336. X    case "X$ans" in
  337. X    X[yY]*) x=1 ;;
  338. X    X[nN]*) x=0 ;;
  339. X    esac
  340. X    $ECHO ""
  341. Xfi
  342. Xcat >>defines.h <<EOF
  343. X/*
  344. X * SIGSETMASK is 1 if your system has the sigsetmask() call.
  345. X * This is normally the case only for BSD 4.2,
  346. X * not for BSD 4.1 or System 5.
  347. X */
  348. X#define    SIGSETMASK    $x
  349. X
  350. XEOF
  351. X
  352. X
  353. X
  354. Xif [ "$sys" = "bsd" ]
  355. Xthen
  356. X    def=2; REGCMP=0;RECOMP=1
  357. Xelse
  358. X    def=1; REGCMP=1;RECOMP=0
  359. Xfi
  360. Xif [ $alldefault = 0 ]
  361. Xthen
  362. X    $ECHO "Most System V systems have the regcmp() function."
  363. X    $ECHO "Most Berkeley-derived systems have the re_comp() function."
  364. X    $ECHO "Does your system have:"
  365. X    $ECHO "  1. regcmp"
  366. X    $ECHO "  2. re_comp"
  367. X    $ECHO "  3. neither   [$def] \c"
  368. X    read ans
  369. X    case "X$ans" in
  370. X    X1) REGCMP=1;RECOMP=0 ;;
  371. X    X2) REGCMP=0;RECOMP=1 ;;
  372. X    X3) REGCMP=0;RECOMP=0 ;;
  373. X    esac
  374. X    $ECHO ""
  375. Xfi
  376. Xcat >>defines.h <<EOF
  377. X/*
  378. X * REGCMP is 1 if your system has the regcmp() function.
  379. X * This is normally the case for System 5.
  380. X * RECOMP is 1 if your system has the re_comp() function.
  381. X * This is normally the case for BSD.
  382. X * If neither is 1, pattern matching is supported, but without metacharacters.
  383. X */
  384. X#define    REGCMP        $REGCMP
  385. X#define    RECOMP        $RECOMP
  386. X
  387. XEOF
  388. X
  389. X
  390. X
  391. X
  392. Xdef=yes
  393. Xx=1
  394. Xif [ $alloptional = 0 ]
  395. Xthen
  396. X    $ECHO "Do you wish to allow shell escapes? [$def] \c"
  397. X    read ans
  398. X    case "X$ans" in
  399. X    X[yY]*) x=1 ;;
  400. X    X[nN]*) x=0 ;;
  401. X    esac
  402. X    $ECHO ""
  403. Xfi
  404. Xcat >>defines.h <<EOF
  405. X/*
  406. X * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
  407. X * (This is possible only if your system supplies the system() function.)
  408. X */
  409. X#define    SHELL_ESCAPE    $x
  410. X
  411. XEOF
  412. X
  413. X
  414. X
  415. Xdef=yes
  416. Xx=1
  417. Xedname="vi"
  418. Xif [ $alloptional = 0 ]
  419. Xthen
  420. X    $ECHO "Do you wish to allow editor escapes? [$def] \c"
  421. X    read ans
  422. X    case "X$ans" in
  423. X    X[nN]*) x=0; edname="" ;;
  424. X    X[yY]*) x=1
  425. X        $ECHO "What is the pathname of the default editor? [$edname] \c"
  426. X        read ans 
  427. X        if [ "x$ans" != "x" ]
  428. X        then
  429. X            edname=$ans
  430. X        fi
  431. X        ;;
  432. X    esac
  433. X    $ECHO ""
  434. Xfi
  435. Xcat >>defines.h <<EOF
  436. X/*
  437. X * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
  438. X * (This is possible only if your system supplies the system() function.)
  439. X * EDIT_PGM is the name of the (default) editor to be invoked.
  440. X */
  441. X#define    EDITOR        $x
  442. X#define    EDIT_PGM    "$edname"
  443. X
  444. XEOF
  445. X
  446. X
  447. X
  448. X
  449. Xdef=yes
  450. Xx=1
  451. Xif [ $alloptional = 0 ]
  452. Xthen
  453. X    $ECHO "Do you wish to support \"tag\" files? [$def] \c"
  454. X    read ans
  455. X    case "X$ans" in
  456. X    X[yY]*) x=1 ;;
  457. X    X[nN]*) x=0 ;;
  458. X    esac
  459. X    $ECHO ""
  460. Xfi
  461. Xcat >>defines.h <<EOF
  462. X/*
  463. X * TAGS is 1 if you wish to support tag files.
  464. X */
  465. X#define    TAGS        $x
  466. X
  467. XEOF
  468. X
  469. X
  470. X
  471. Xdef=yes
  472. Xx=1
  473. Xif [ $alloptional = 0 ]
  474. Xthen
  475. X    $ECHO "Do you wish to allow user-defined key definitions? [$def] \c"
  476. X    read ans
  477. X    case "X$ans" in
  478. X    X[yY]*) x=1 ;;
  479. X    X[nN]*) x=0 ;;
  480. X    esac
  481. X    $ECHO ""
  482. Xfi
  483. XUSERFILE=$x
  484. Xcat >>defines.h <<EOF
  485. X/*
  486. X * USERFILE is 1 if you wish to allow a .less file to specify 
  487. X * user-defined key bindings.
  488. X */
  489. X#define    USERFILE    $x
  490. X
  491. XEOF
  492. X
  493. X
  494. X
  495. Xdef=yes
  496. Xx=1
  497. Xif [ $alldefault = 0 ]
  498. Xthen
  499. X    $ECHO "If your system provides the popen() function and"
  500. X    $ECHO "the \"$ECHO\" shell command, you may allow shell metacharacters" 
  501. X    $ECHO "to be expanded in filenames."
  502. X    $ECHO "Do you wish to allow shell metacharacters in filenames? [$def] \c"
  503. X    read ans
  504. X    case "X$ans" in
  505. X    X[yY]*) x=1 ;;
  506. X    X[nN]*) x=0 ;;
  507. X    esac
  508. X    $ECHO ""
  509. Xfi
  510. Xcat >>defines.h <<EOF
  511. X/*
  512. X * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
  513. X * This will generally work if your system provides the "popen" function
  514. X * and the "$ECHO" shell command.
  515. X */
  516. X#define    GLOB        $x
  517. X
  518. XEOF
  519. X
  520. X
  521. X
  522. Xdef=yes
  523. Xx=1
  524. Xif [ $alloptional = 0 ]
  525. Xthen
  526. X    $ECHO "Do you wish to allow log files (-l option)? [$def] \c"
  527. X    read ans
  528. X    case "X$ans" in
  529. X    X[yY]*) x=1 ;;
  530. X    X[nN]*) x=0 ;;
  531. X    esac
  532. X    $ECHO ""
  533. Xfi
  534. Xcat >>defines.h <<EOF
  535. X/*
  536. X * LOGFILE is 1 if you wish to allow the -l option (to create log files).
  537. X */
  538. X#define    LOGFILE        $x
  539. X
  540. XEOF
  541. X
  542. Xcat >>defines.h <<EOF
  543. X/*
  544. X * ONLY_RETURN is 1 if you want RETURN to be the only input which
  545. X * will continue past an error message.
  546. X * Otherwise, any key will continue past an error message.
  547. X */
  548. X#define    ONLY_RETURN    0
  549. X
  550. XEOF
  551. X
  552. Xcat >>makefile <<EOF
  553. X
  554. X##########################################################################
  555. X# Compilation environment.
  556. X##########################################################################
  557. X
  558. XEOF
  559. X
  560. X
  561. X
  562. Xif [ "$xenix" = "1" ]
  563. Xthen
  564. X    LIBS="-ltermlib"
  565. Xelif [ "$sys" = "bsd" ]
  566. Xthen
  567. X    LIBS="-ltermcap"
  568. Xelse
  569. X    LIBS="-lcurses -ltermcap -lPW"
  570. Xfi
  571. Xif [ $alldefault = 0 ]
  572. Xthen
  573. X    $ECHO "To build \"less\", you must link with libraries supplied by your system."
  574. X    $ECHO "(If this needs to be changed later, edit the makefile"
  575. X    $ECHO "and change the definition of LIBS.)"
  576. X    $ECHO "What libraries should be used [$LIBS] \c"
  577. X    read ans
  578. X    if [ "X$ans" != "X" ]
  579. X    then
  580. X        LIBS="$ans"
  581. X    fi
  582. X    $ECHO ""
  583. Xfi
  584. Xcat >>makefile <<EOF
  585. X# LIBS is the list of libraries needed.
  586. XLIBS = $LIBS
  587. X
  588. XEOF
  589. X
  590. X
  591. X
  592. XINSTALL_LESS="/usr/local/bin/less"
  593. XINSTALL_KEY="/usr/local/bin/lesskey"
  594. XINSTALL_HELP="/usr/local/bin/less.help"
  595. XINSTALL_LESSMAN="/usr/man/man1/less.1"
  596. XINSTALL_KEYMAN="/usr/man/man1/lesskey.1"
  597. XLESS_MANUAL="less.nro"
  598. XKEY_MANUAL="lesskey.nro"
  599. Xif [ $alldefault = 0 ]
  600. Xthen
  601. X    $ECHO "What is the name of the \"public\" (installed) version of less?"
  602. X    $ECHO " [$INSTALL_LESS] \c"
  603. X    read ans
  604. X    if [ "X$ans" != "X" ]
  605. X    then
  606. X        INSTALL_LESS="$ans"
  607. X    fi
  608. X    $ECHO "What is the name of the \"public\" (installed) version of lesskey?"
  609. X    $ECHO " [$INSTALL_KEY] \c"
  610. X    read ans
  611. X    if [ "X$ans" != "X" ]
  612. X    then
  613. X        INSTALL_KEY="$ans"
  614. X    fi
  615. X    $ECHO "What is the name of the \"public\" (installed) version of the help file?"
  616. X    $ECHO " [$INSTALL_HELP] \c"
  617. X    read ans
  618. X    if [ "X$ans" != "X" ]
  619. X    then
  620. X        INSTALL_HELP="$ans"
  621. X    fi
  622. X    $ECHO "What is the name of the \"public\" (installed) version of the less manual page?"
  623. X    $ECHO " [$INSTALL_LESSMAN] \c"
  624. X    read ans
  625. X    if [ "X$ans" != "X" ]
  626. X    then
  627. X        INSTALL_LESSMAN="$ans"
  628. X    fi
  629. X    $ECHO "What is the name of the \"public\" (installed) version of the lesskey manual page?"
  630. X    $ECHO " [$INSTALL_KEYMAN] \c"
  631. X    read ans
  632. X    if [ "X$ans" != "X" ]
  633. X    then
  634. X        INSTALL_KEYMAN="$ans"
  635. X    fi
  636. X    $ECHO ""
  637. Xfi
  638. Xcat >>makefile <<EOF
  639. X# INSTALL_LESS is a list of the public versions of less.
  640. X# INSTALL_KEY is a list of the public versions of lesskey.
  641. X# INSTALL_HELP is a list of the public version of the help file.
  642. X# INSTALL_LESSMAN is a list of the public versions of the less manual page.
  643. X# INSTALL_KEYMAN is a list of the public versions of the lesskey manual page.
  644. XINSTALL_LESS =        \$(ROOT)$INSTALL_LESS
  645. XINSTALL_KEY =        \$(ROOT)$INSTALL_KEY
  646. XINSTALL_HELP =        \$(ROOT)$INSTALL_HELP
  647. XINSTALL_LESSMAN =    \$(ROOT)$INSTALL_LESSMAN
  648. XINSTALL_KEYMAN =    \$(ROOT)$INSTALL_KEYMAN
  649. XLESS_MANUAL =        $LESS_MANUAL
  650. XKEY_MANUAL =        $KEY_MANUAL
  651. XHELPFILE =        $INSTALL_HELP
  652. X
  653. X
  654. XEOF
  655. X
  656. X
  657. X
  658. Xcat >>makefile <<"EOF"
  659. X# OPTIM is passed to the compiler and the loader.
  660. X# It is normally "-O" but may be, for example, "-g".
  661. XOPTIM = -O
  662. X
  663. XCFLAGS = $(OPTIM)
  664. X
  665. X
  666. X
  667. X##########################################################################
  668. X# Files
  669. X##########################################################################
  670. X
  671. XSRC1 =    main.c option.c prim.c ch.c position.c input.c linenum.c
  672. XSRC2 =    screen.c prompt.c line.c signal.c os.c help.c ttyin.c command.c
  673. XSRC3 =    output.c decode.c tags.c version.c
  674. XSRC =    $(SRC1) $(SRC2) $(SRC3)
  675. XOBJ =    main.o option.o prim.o ch.o position.o input.o output.o \
  676. X    screen.o prompt.o line.o signal.o os.o help.o ttyin.o \
  677. X    decode.o command.o linenum.o tags.o version.o
  678. X
  679. X
  680. X##########################################################################
  681. X# Rules for building stuff
  682. X##########################################################################
  683. X
  684. XEOF
  685. X
  686. Xif [ "$USERFILE" = "1" ]
  687. Xthen
  688. X    cat >>makefile <<"EOF"
  689. Xall: less lesskey
  690. Xinstall: install_less install_help install_key install_lman install_kman
  691. XEOF
  692. Xelse
  693. X    cat >>makefile <<"EOF"
  694. Xall: less
  695. Xinstall: install_less install_help install_lman
  696. XEOF
  697. Xfi
  698. X
  699. Xcat >>makefile <<"EOF"
  700. X
  701. Xless: $(OBJ)
  702. X    $(CC) $(LDFLAGS) $(OPTIM) -o less $(OBJ) $(LIBS) $(LDLIBS)
  703. X
  704. Xlesskey: lesskey.o
  705. X    $(CC) $(LDFLAGS) $(OPTIM) -o lesskey lesskey.o $(LDLIBS)
  706. X
  707. X# help.o depends on makefile for the definition of HELPFILE
  708. Xhelp.o: makefile
  709. X    $(CC) $(CFLAGS) -c -DHELPFILE=\"$(HELPFILE)\" help.c
  710. X
  711. Xinstall_less: less
  712. X    for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
  713. X    touch install_less
  714. X
  715. Xinstall_key: lesskey
  716. X    for f in $(INSTALL_KEY); do  rm -f $$f; cp lesskey $$f;  done
  717. X    touch install_key
  718. X
  719. Xinstall_help: less.help
  720. X    for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
  721. X    touch install_help
  722. X
  723. Xinstall_lman: $(LESS_MANUAL) 
  724. X    for f in $(INSTALL_LESSMAN); do  rm -f $$f; cp $(LESS_MANUAL) $$f;  done
  725. X    touch install_lman
  726. X
  727. Xinstall_kman: $(KEY_MANUAL)
  728. X    for f in $(INSTALL_KEYMAN); do  rm -f $$f; cp $(KEY_MANUAL) $$f;  done
  729. X    touch install_kman
  730. X
  731. X##########################################################################
  732. X# Maintenance
  733. X##########################################################################
  734. X
  735. Xlint:
  736. X    lint -hp $(SRC)
  737. X
  738. Xnewfuncs funcs.h:
  739. X    if [ -f funcs.h ]; then mv funcs.h funcs.h.OLD; fi
  740. X    awk -f mkfuncs.awk $(SRC) >funcs.h
  741. X
  742. Xclean:
  743. X    rm -f $(OBJ) lesskey.o less lesskey vecho
  744. X
  745. Xclobber:
  746. X    rm -f *.o less lesskey vecho install_less install_key \
  747. X        install_help install_lman install_kman
  748. X
  749. Xshar:
  750. X    shar -v linstall less.h position.h funcs.h cmd.h \
  751. X        vecho.c lesskey.c less.nro lesskey.nro lesskey.man > less.shar.a
  752. X    shar -v $(SRC1) > less.shar.b
  753. X    shar -v $(SRC2) > less.shar.c
  754. X    shar -v $(SRC3) less.man README less.help *.awk >less.shar.d
  755. X
  756. X
  757. X##########################################################################
  758. X# Dependencies
  759. X##########################################################################
  760. X
  761. X$(OBJ): less.h funcs.h defines.h position.h
  762. Xcommand.o decode.o: cmd.h
  763. Xlesskey.o: less.h funcs.h defines.h cmd.h
  764. X
  765. XEOF
  766. X$ECHO ""
  767. X
  768. X$ECHO "The makefile has been built."
  769. X$ECHO "You should check it to make sure everything is as you want it to be."
  770. X$ECHO "When you are satisfied with the makefile, just type \"make\""
  771. X$ECHO "and \"less\" will be built."
  772. END_OF_FILE
  773. echo shar: Extracting \"less.h\"
  774. sed "s/^X//" >'less.h' <<'END_OF_FILE'
  775. X/*
  776. X * Standard include file for "less".
  777. X */
  778. X
  779. X/*
  780. X * Include the file of compile-time options.
  781. X */
  782. X#include "defines.h"
  783. X
  784. X/*
  785. X * Language details.
  786. X */
  787. X#if !VOID
  788. X#define    void  int
  789. X#endif
  790. X#define    public        /* PUBLIC FUNCTION */
  791. X
  792. X/*
  793. X * Special types and constants.
  794. X */
  795. Xtypedef long        POSITION;
  796. X/*
  797. X * {{ Warning: if POSITION is changed to other than "long",
  798. X *    you may have to change some of the printfs which use "%ld"
  799. X *    to print a variable of type POSITION. }}
  800. X */
  801. X
  802. X#define    NULL_POSITION    ((POSITION)(-1))
  803. X
  804. X/*
  805. X * The type of signal handler functions.
  806. X * Usually int, although it should be void.
  807. X */
  808. Xtypedef    int        HANDLER;
  809. X
  810. X
  811. X#define    FILENAME    128    /* Max size of a filename */
  812. X
  813. X#define    EOI        (0)
  814. X#ifndef NULL
  815. X#define    NULL        (0)
  816. X#endif
  817. X
  818. X#define    READ_INTR    (-2)
  819. X
  820. X/* How quiet should we be? */
  821. X#define    NOT_QUIET    0    /* Ring bell at eof and for errors */
  822. X#define    LITTLE_QUIET    1    /* Ring bell only for errors */
  823. X#define    VERY_QUIET    2    /* Never ring bell */
  824. X
  825. X/* How should we prompt? */
  826. X#define    PR_SHORT    0    /* Prompt with colon */
  827. X#define    PR_MEDIUM    1    /* Prompt with message */
  828. X#define    PR_LONG        2    /* Prompt with longer message */
  829. X
  830. X/* How should we handle backspaces? */
  831. X#define    BS_SPECIAL    0    /* Do special things for underlining and bold */
  832. X#define    BS_NORMAL    1    /* \b treated as normal char; actually output */
  833. X#define    BS_CONTROL    2    /* \b treated as control char; prints as ^H */
  834. X
  835. X/* Special chars used to tell put_line() to do something special */
  836. X#define    UL_CHAR        '\201'    /* Enter underline mode */
  837. X#define    UE_CHAR        '\202'    /* Exit underline mode */
  838. X#define    BO_CHAR        '\203'    /* Enter boldface mode */
  839. X#define    BE_CHAR        '\204'    /* Exit boldface mode */
  840. X
  841. X#define    CONTROL(c)        ((c)&037)
  842. X#define    SIGNAL(sig,func)    signal(sig,func)
  843. X
  844. X/* Library function declarations */
  845. Xoffset_t lseek();
  846. Xchar *calloc();
  847. X
  848. X#include "funcs.h"
  849. END_OF_FILE
  850. echo shar: Extracting \"position.h\"
  851. sed "s/^X//" >'position.h' <<'END_OF_FILE'
  852. X/*
  853. X * Include file for interfacing to position.c modules.
  854. X */
  855. X#define    TOP        (0)
  856. X#define    TOP_PLUS_ONE    (1)
  857. X#define    BOTTOM        (-1)
  858. X#define    BOTTOM_PLUS_ONE    (-2)
  859. X#define    MIDDLE        (-3)
  860. END_OF_FILE
  861. echo shar: Extracting \"funcs.h\"
  862. sed "s/^X//" >'funcs.h' <<'END_OF_FILE'
  863. X    public void edit ();
  864. X    public void next_file ();
  865. X    public void prev_file ();
  866. X    public void strtcpy ();
  867. X    public char * save ();
  868. X    public void quit ();
  869. X    public void init_option ();
  870. X    public void toggle_option ();
  871. X    public int single_char_option ();
  872. X    public void scan_option ();
  873. X    public int getnum ();
  874. X    public void forward ();
  875. X    public void backward ();
  876. X    public void repaint ();
  877. X    public void jump_forw ();
  878. X    public void jump_back ();
  879. X    public void jump_percent ();
  880. X    public void jump_loc ();
  881. X    public void init_mark ();
  882. X    public void setmark ();
  883. X    public void lastmark ();
  884. X    public void gomark ();
  885. X    public int get_back_scroll ();
  886. X    public void search ();
  887. X    public void end_logfile ();
  888. X    public void sync_logfile ();
  889. X    public int ch_seek ();
  890. X    public int ch_end_seek ();
  891. X    public int ch_beg_seek ();
  892. X    public POSITION ch_length ();
  893. X    public POSITION ch_tell ();
  894. X    public int ch_forw_get ();
  895. X    public int ch_back_get ();
  896. X    public void ch_init ();
  897. X    public POSITION position ();
  898. X    public void add_forw_pos ();
  899. X    public void add_back_pos ();
  900. X    public void pos_clear ();
  901. X    public int onscreen ();
  902. X    public POSITION forw_line ();
  903. X    public POSITION back_line ();
  904. X    public void clr_linenum ();
  905. X    public void add_lnum ();
  906. X    public int find_linenum ();
  907. X    public int currline ();
  908. X    public void raw_mode ();
  909. X    public void get_term ();
  910. X    public void init ();
  911. X    public void deinit ();
  912. X    public void home ();
  913. X    public void add_line ();
  914. X    public void lower_left ();
  915. X    public void bell ();
  916. X    public void vbell ();
  917. X    public void clear ();
  918. X    public void clear_eol ();
  919. X    public void so_enter ();
  920. X    public void so_exit ();
  921. X    public void ul_enter ();
  922. X    public void ul_exit ();
  923. X    public void bo_enter ();
  924. X    public void bo_exit ();
  925. X    public void backspace ();
  926. X    public void putbs ();
  927. X    public void init_prompt ();
  928. X    public char * eq_message ();
  929. X    public char * pr_string ();
  930. X    public void prewind ();
  931. X    public int pappend ();
  932. X    public POSITION forw_raw_line ();
  933. X    public POSITION back_raw_line ();
  934. X    public HANDLER winch ();
  935. X    public HANDLER winch ();
  936. X    public void init_signals ();
  937. X    public int psignals ();
  938. X    public void lsystem ();
  939. X    public int iread ();
  940. X    public void intread ();
  941. X    public long get_time ();
  942. X    public char * glob ();
  943. X    public char * glob ();
  944. X    public char * bad_file ();
  945. X    public char * bad_file ();
  946. X    public char * errno_message ();
  947. X    public char * errno_message ();
  948. X    public void help ();
  949. X    public void open_getchr ();
  950. X    public int getchr ();
  951. X    public void commands ();
  952. X    public void put_line ();
  953. X    public int control_char ();
  954. X    public int carat_char ();
  955. X    public void flush ();
  956. X    public void dropout ();
  957. X    public void putchr ();
  958. X    public void putstr ();
  959. X    public void error ();
  960. X    public void ierror ();
  961. X    public int cmd_decode ();
  962. X    public void noprefix ();
  963. X    public void init_cmd ();
  964. X    public int findtag ();
  965. X    public int tagsearch ();
  966. END_OF_FILE
  967. echo shar: Extracting \"cmd.h\"
  968. sed "s/^X//" >'cmd.h' <<'END_OF_FILE'
  969. X#define    MAX_USERCMD        200
  970. X#define    MAX_CMDLEN        16
  971. X
  972. X#define    A_AGAIN_SEARCH        1
  973. X#define    A_B_LINE        2
  974. X#define    A_B_SCREEN        3
  975. X#define    A_B_SCROLL        4
  976. X#define    A_B_SEARCH        5
  977. X#define    A_DIGIT            6
  978. X#define    A_DISP_OPTION        7
  979. X#define    A_DEBUG            8
  980. X#define    A_EXAMINE        9
  981. X#define    A_FIRSTCMD        10
  982. X#define    A_FREPAINT        11
  983. X#define    A_F_LINE        12
  984. X#define    A_F_SCREEN        13
  985. X#define    A_F_SCROLL        14
  986. X#define    A_F_SEARCH        15
  987. X#define    A_GOEND            16
  988. X#define    A_GOLINE        17
  989. X#define    A_GOMARK        18
  990. X#define    A_HELP            19
  991. X#define    A_NEXT_FILE        20
  992. X#define    A_PERCENT        21
  993. X#define    A_PREFIX        22
  994. X#define    A_PREV_FILE        23
  995. X#define    A_QUIT            24
  996. X#define    A_REPAINT        25
  997. X#define    A_SETMARK        26
  998. X#define    A_SHELL            27
  999. X#define    A_STAT            28
  1000. X
  1001. X#define    A_TOGGLE_OPTION        30
  1002. X#define    A_VERSION        31
  1003. X#define    A_VISUAL        32
  1004. X
  1005. X#define    A_INVALID        100
  1006. X#define    A_NOACTION        101
  1007. END_OF_FILE
  1008. echo shar: Extracting \"vecho.c\"
  1009. sed "s/^X//" >'vecho.c' <<'END_OF_FILE'
  1010. X/*
  1011. X * This dumb little program emulates the System V "echo" command,
  1012. X * to accomodate BSD systems which don't understand the \c escape,
  1013. X * meaning don't echo a newline.  BSD uses "echo -n".
  1014. X */
  1015. X
  1016. X#include <stdio.h>
  1017. X
  1018. Xint putnl;
  1019. X
  1020. Xmain(argc, argv)
  1021. X    int argc;
  1022. X    char *argv[];
  1023. X{
  1024. X    putnl = 1;
  1025. X    while (--argc > 0)
  1026. X    {
  1027. X        vecho(*++argv);
  1028. X        if (argc > 1)
  1029. X            putchar(' ');
  1030. X    }
  1031. X    if (putnl)
  1032. X        putchar('\n');
  1033. X}
  1034. X
  1035. Xvecho(str)
  1036. X    char *str;
  1037. X{
  1038. X    register char *s;
  1039. X
  1040. X    for (s = str;  *s != '\0';  s++)
  1041. X    {
  1042. X        if (*s == '\\' && s[1] == 'c')
  1043. X        {
  1044. X            putnl = 0;
  1045. X            return;
  1046. X        }
  1047. X        putchar(*s);
  1048. X    }
  1049. X}
  1050. END_OF_FILE
  1051. echo shar: Extracting \"lesskey.c\"
  1052. sed "s/^X//" >'lesskey.c' <<'END_OF_FILE'
  1053. X/*
  1054. X *    lesskey [-o output] [input]
  1055. X *
  1056. X *    Make a .less file.
  1057. X *    If no input file is specified, standard input is used.
  1058. X *    If no output file is specified, $HOME/.less is used.
  1059. X *
  1060. X *    The .less file is used to specify (to "less") user-defined
  1061. X *    key bindings.  Basically any sequence of 1 to MAX_CMDLEN
  1062. X *    keystrokes may be bound to an existing less function.
  1063. X *
  1064. X *    The input file is an ascii file consisting of a 
  1065. X *    sequence of lines of the form:
  1066. X *        string <whitespace> action <newline>
  1067. X *
  1068. X *    "string" is a sequence of command characters which form
  1069. X *        the new user-defined command.  The command
  1070. X *        characters may be:
  1071. X *        1. The actual character itself.
  1072. X *        2. A character preceeded by ^ to specify a
  1073. X *           control character (e.g. ^X means control-X).
  1074. X *        3. Any character (other than an octal digit) preceeded by
  1075. X *           a \ to specify the character itself (characters which
  1076. X *           must be preceeded by \ include ^, \, and whitespace.
  1077. X *        4. A backslash followed by one to three octal digits
  1078. X *           to specify a character by its octal value.
  1079. X *    "action" is the name of a "less" action, from the table below.
  1080. X *
  1081. X *    Blank lines and lines which start with # are ignored.
  1082. X *
  1083. X *
  1084. X *    The output file is a non-ascii file, consisting of
  1085. X *    zero or more byte sequences of the form:
  1086. X *        string <0> <action>
  1087. X *
  1088. X *    "string" is the command string.
  1089. X *    "<0>" is one null byte.
  1090. X *    "<action>" is one byte containing the action code (the A_xxx value).
  1091. X *
  1092. X *
  1093. X *        Revision history
  1094. X *
  1095. X *    v1: Initial version.                    10/13/87  mark
  1096. X */
  1097. X
  1098. X#include <stdio.h>
  1099. X#include "less.h"
  1100. X#include "cmd.h"
  1101. X
  1102. Xchar usertable[MAX_USERCMD];
  1103. X
  1104. Xstruct cmdname
  1105. X{
  1106. X    char *cn_name;
  1107. X    int cn_action;
  1108. X} cmdnames[] = 
  1109. X{
  1110. X    "back-line",        A_B_LINE,
  1111. X    "back-screen",        A_B_SCREEN,
  1112. X    "back-scroll",        A_B_SCROLL,
  1113. X    "back-search",        A_B_SEARCH,
  1114. X    "debug",        A_DEBUG,
  1115. X    "display-flag",        A_DISP_OPTION,
  1116. X    "display-option",    A_DISP_OPTION,
  1117. X    "end",            A_GOEND,
  1118. X    "examine",        A_EXAMINE,
  1119. X    "first-cmd",        A_FIRSTCMD,
  1120. X    "firstcmd",        A_FIRSTCMD,
  1121. X    "flush-repaint",    A_FREPAINT,
  1122. X    "forw-line",        A_F_LINE,
  1123. X    "forw-screen",        A_F_SCREEN,
  1124. X    "forw-scroll",        A_F_SCROLL,
  1125. X    "forw-search",        A_F_SEARCH,
  1126. X    "goto-end",        A_GOEND,
  1127. X    "goto-line",        A_GOLINE,
  1128. X    "goto-mark",        A_GOMARK,
  1129. X    "help",            A_HELP,
  1130. X    "invalid",        A_NOACTION,
  1131. X    "next-file",        A_NEXT_FILE,
  1132. X    "noaction",        A_NOACTION,
  1133. X    "percent",        A_PERCENT,
  1134. X    "prev-file",        A_PREV_FILE,
  1135. X    "quit",            A_QUIT,
  1136. X    "repaint",        A_REPAINT,
  1137. X    "repaint-flush",    A_FREPAINT,
  1138. X    "repeat-search",    A_AGAIN_SEARCH,
  1139. X    "set-mark",        A_SETMARK,
  1140. X    "shell",        A_SHELL,
  1141. X    "status",        A_STAT,
  1142. X    "toggle-flag",        A_TOGGLE_OPTION,
  1143. X    "toggle-option",    A_TOGGLE_OPTION,
  1144. X    "version",        A_VERSION,
  1145. X    "visual",        A_VISUAL,
  1146. X    NULL,            0
  1147. X};
  1148. X
  1149. Xmain(argc, argv)
  1150. X    int argc;
  1151. X    char *argv[];
  1152. X{
  1153. X    char *p;        /* {{ Can't be register since we use &p }} */
  1154. X    register char *up;    /* Pointer into usertable */
  1155. X    FILE *desc;        /* Description file (input) */
  1156. X    FILE *out;        /* Output file */
  1157. X    int linenum;        /* Line number in input file */
  1158. X    char *currcmd;        /* Start of current command string */
  1159. X    int errors;
  1160. X    int i;
  1161. X    char line[100];
  1162. X    char *outfile;
  1163. X
  1164. X    extern char *getenv();
  1165. X
  1166. X    /*
  1167. X     * Process command line arguments.
  1168. X     */
  1169. X    outfile = NULL;
  1170. X    while (--argc > 0 && **(++argv) == '-')
  1171. X    {
  1172. X        switch (argv[0][1])
  1173. X        {
  1174. X        case 'o':
  1175. X            outfile = &argv[0][2];
  1176. X            if (*outfile == '\0')
  1177. X            {
  1178. X                if (--argc <= 0)
  1179. X                    usage();
  1180. X                outfile = *(++argv);
  1181. X            }
  1182. X            break;
  1183. X        default:
  1184. X            usage();
  1185. X        }
  1186. X    }
  1187. X    if (argc > 1)
  1188. X        usage();
  1189. X
  1190. X
  1191. X    /*
  1192. X     * Open the input file, or use standard input if none specified.
  1193. X     */
  1194. X    if (argc > 0)
  1195. X    {
  1196. X        if ((desc = fopen(*argv, "r")) == NULL)
  1197. X        {
  1198. X            perror(*argv);
  1199. X            exit(1);
  1200. X        }
  1201. X    } else
  1202. X        desc = stdin;
  1203. X
  1204. X    /*
  1205. X     * Read the input file, one line at a time.
  1206. X     * Each line consists of a command string,
  1207. X     * followed by white space, followed by an action name.
  1208. X     */
  1209. X    linenum = 0;
  1210. X    errors = 0;
  1211. X    up = usertable;
  1212. X    while (fgets(line, sizeof(line), desc) != NULL)
  1213. X    {
  1214. X        ++linenum;
  1215. X
  1216. X        /*
  1217. X         * Skip leading white space.
  1218. X         * Replace the final newline with a null byte.
  1219. X         * Ignore blank lines and comment lines.
  1220. X         */
  1221. X        p = line;
  1222. X        while (*p == ' ' || *p == '\t')
  1223. X            ++p;
  1224. X        for (i = 0;  p[i] != '\n' && p[i] != '\0';  i++)
  1225. X            ;
  1226. X        p[i] = '\0';
  1227. X        if (*p == '#' || *p == '\0')
  1228. X            continue;
  1229. X
  1230. X        /*
  1231. X         * Parse the command string and store it in the usertable.
  1232. X         */
  1233. X        currcmd = up;
  1234. X        do
  1235. X        {
  1236. X            if (up >= usertable + MAX_USERCMD)
  1237. X            {
  1238. X                fprintf(stderr, "too many commands, line %d\n",
  1239. X                    linenum);
  1240. X                exit(1);
  1241. X            }
  1242. X            if (up >= currcmd + MAX_CMDLEN)
  1243. X            {
  1244. X                fprintf(stderr, "command too long on line %d\n",
  1245. X                    linenum);
  1246. X                errors++;
  1247. X                break;
  1248. X            }
  1249. X
  1250. X            *up++ = tchar(&p);
  1251. X
  1252. X        } while (*p != ' ' && *p != '\t' && *p != '\0');
  1253. X
  1254. X        /*
  1255. X         * Terminate the command string with a null byte.
  1256. X         */
  1257. X        *up++ = '\0';
  1258. X
  1259. X        /*
  1260. X         * Skip white space between the command string
  1261. X         * and the action name.
  1262. X         * Terminate the action name if it is followed
  1263. X         * by whitespace or a # comment.
  1264. X         */
  1265. X        if (*p == '\0')
  1266. X        {
  1267. X            fprintf(stderr, "missing whitespace on line %d\n",
  1268. X                linenum);
  1269. X            errors++;
  1270. X            continue;
  1271. X        }
  1272. X        while (*p == ' ' || *p == '\t')
  1273. X            ++p;
  1274. X        for (i = 0;  p[i] != ' ' && p[i] != '\t' && 
  1275. X                 p[i] != '#' && p[i] != '\0';  i++)
  1276. X            ;
  1277. X        p[i] = '\0';
  1278. X
  1279. X        /*
  1280. X         * Parse the action name and store it in the usertable.
  1281. X         */
  1282. X        for (i = 0;  cmdnames[i].cn_name != NULL;  i++)
  1283. X            if (strcmp(cmdnames[i].cn_name, p) == 0)
  1284. X                break;
  1285. X        if (cmdnames[i].cn_name == NULL)
  1286. X        {
  1287. X            fprintf(stderr, "unknown action <%s> on line %d\n",
  1288. X                p, linenum);
  1289. X            errors++;
  1290. X            continue;
  1291. X        }
  1292. X        *up++ = cmdnames[i].cn_action;
  1293. X    }
  1294. X
  1295. X    if (errors > 0)
  1296. X    {
  1297. X        fprintf(stderr, "%d errors; no output produced\n", errors);
  1298. X        exit(1);
  1299. X    }
  1300. X
  1301. X    /*
  1302. X     * Write the output file.
  1303. X     * If no output file was specified, use "$HOME/.less"
  1304. X     */
  1305. X    if (outfile == NULL)
  1306. X    {
  1307. X        p = getenv("HOME");
  1308. X        if (p == NULL)
  1309. X        {
  1310. X            fprintf(stderr, "cannot find $HOME\n");
  1311. X            exit(1);
  1312. X        }
  1313. X        strcpy(line, p);
  1314. X        strcat(line, "/.less");
  1315. X        outfile = line;
  1316. X    }
  1317. X    if ((out = fopen(outfile, "w")) == NULL)
  1318. X        perror(outfile);
  1319. X    else
  1320. X        fwrite((char *)usertable, 1, up-usertable, out);
  1321. X}
  1322. X
  1323. X/*
  1324. X * Parse one character of the command string.
  1325. X */
  1326. Xtchar(pp)
  1327. X    char **pp;
  1328. X{
  1329. X    register char *p;
  1330. X    register char ch;
  1331. X    register int i;
  1332. X
  1333. X    p = *pp;
  1334. X    switch (*p)
  1335. X    {
  1336. X    case '\\':
  1337. X        if (*++p >= '0' && *p <= '7')
  1338. X        {
  1339. X            /*
  1340. X             * Parse an octal number.
  1341. X             */
  1342. X            ch = 0;
  1343. X            i = 0;
  1344. X            do
  1345. X                ch = 8*ch + (*p - '0');
  1346. X            while (*++p >= '0' && *p <= '7' && ++i < 3);
  1347. X            *pp = p;
  1348. X            return (ch);
  1349. X        }
  1350. X        /*
  1351. X         * Backslash followed by a char just means that char.
  1352. X         */
  1353. X        *pp = p+1;
  1354. X        return (*p);
  1355. X    case '^':
  1356. X        /*
  1357. X         * Carat means CONTROL.
  1358. X         */
  1359. X        *pp = p+2;
  1360. X        return (CONTROL(p[1]));
  1361. X    }
  1362. X    *pp = p+1;
  1363. X    return (*p);
  1364. X}
  1365. X
  1366. Xusage()
  1367. X{
  1368. X    fprintf(stderr, "usage: lesskey [-o output] [input]\n");
  1369. X    exit(1);
  1370. X}
  1371. END_OF_FILE
  1372. echo shar: Extracting \"less.nro\"
  1373. sed "s/^X//" >'less.nro' <<'END_OF_FILE'
  1374. X.TH LESS 1
  1375. X.SH NAME
  1376. Xless \- opposite of more
  1377. X.SH SYNOPSIS
  1378. X.B "less [-[+]aABcCdeEimMnqQuUsw] [-b\fIN\fB] [-h\fIN\fB] [-x\fIN\fB] [-[z]\fIN\fB]"
  1379. X.br
  1380. X.B "     [-P[mM=]\fIstring\fB] [-[lL]\fIlogfile\fB] [+\fIcmd\fB]"
  1381. X.br
  1382. X.B "     [-t\fItag\fB] [\fIfilename\fB]..."
  1383. X.SH DESCRIPTION
  1384. X.I Less
  1385. Xis a program similar to 
  1386. X.I more
  1387. X(1), but which allows backwards movement
  1388. Xin the file as well as forward movement.
  1389. XAlso,
  1390. X.I less
  1391. Xdoes not have to read the entire input file before starting,
  1392. Xso with large input files it starts up faster than text editors like
  1393. X.I vi
  1394. X(1).
  1395. X.I Less
  1396. Xuses termcap (or terminfo on some systems),
  1397. Xso it can run on a variety of terminals.
  1398. XThere is even limited support for hardcopy terminals.
  1399. X(On a hardcopy terminal, lines which should be printed at the top
  1400. Xof the screen are prefixed with an up-arrow.)
  1401. X.PP
  1402. XCommands are based on both
  1403. X.I more
  1404. Xand
  1405. X.I vi.
  1406. XCommands may be preceeded by a decimal number, 
  1407. Xcalled N in the descriptions below.
  1408. XThe number is used by some commands, as indicated.
  1409. X
  1410. X.SH COMMANDS
  1411. XIn the following descriptions, ^X means control-X.
  1412. XESC stands for the ESCAPE key; for example ESC-v means the
  1413. Xtwo character sequence "ESCAPE", then "v".
  1414. X.IP H
  1415. XHelp: display a summary of these commands.
  1416. XIf you forget all the other commands, remember this one.
  1417. X.PP
  1418. X.IP "SPACE or f or ^F or ^V"
  1419. XScroll forward N lines, default one window (see option -z below).
  1420. XIf N is more than the screen size, only the final screenful is displayed.
  1421. XWarning: some systems use ^V as a special literalization character.
  1422. X.PP
  1423. X.IP "b or ^B or ESC-v"
  1424. XScroll backward N lines, default one window (see option -z below).
  1425. XIf N is more than the screen size, only the final screenful is displayed.
  1426. X.PP
  1427. X.IP "RETURN or ^N or e or ^E or j or ^J"
  1428. XScroll forward N lines, default 1.
  1429. XThe entire N lines are displayed, even if N is more than the screen size.
  1430. X.PP
  1431. X.IP "y or ^Y or ^P or k or ^K"
  1432. XScroll backward N lines, default 1.
  1433. XThe entire N lines are displayed, even if N is more than the screen size.
  1434. XWarning: some systems use ^Y as a special job control character.
  1435. X.PP
  1436. X.IP "d or ^D"
  1437. XScroll forward N lines, default one half of the screen size.
  1438. XIf N is specified, it becomes the new default for 
  1439. Xsubsequent d and u commands.
  1440. X.PP
  1441. X.IP "u or ^U"
  1442. XScroll backward N lines, default one half of the screen size.
  1443. XIf N is specified, it becomes the new default for 
  1444. Xsubsequent d and u commands.
  1445. X.PP
  1446. X.IP "r or ^R or ^L"
  1447. XRepaint the screen.
  1448. X.PP
  1449. X.IP R
  1450. XRepaint the screen, discarding any buffered input.
  1451. XUseful if the file is changing while it is being viewed.
  1452. X.PP
  1453. X.IP "g or < or ESC-<"
  1454. XGo to line N in the file, default 1 (beginning of file).
  1455. X(Warning: this may be slow if N is large.)
  1456. X.PP
  1457. X.IP "G or > or ESC->"
  1458. XGo to line N in the file, default the end of the file.
  1459. X(Warning: this may be slow if N is large,
  1460. Xor if N is not specified and
  1461. Xstandard input, rather than a file, is being read.)
  1462. X.PP
  1463. X.IP "p or %"
  1464. XGo to a position N percent into the file.
  1465. XN should be between 0 and 100.
  1466. X(This works if standard input is being read, but only if
  1467. X.I less
  1468. Xhas already read to the end of the file.
  1469. XIt is always fast, but not always useful.)
  1470. X.PP
  1471. X.IP m
  1472. XFollowed by any lowercase letter, 
  1473. Xmarks the current position with that letter.
  1474. X.PP
  1475. X.IP "'"
  1476. X(Single quote.)
  1477. XFollowed by any lowercase letter, returns to the position which
  1478. Xwas previously marked with that letter.
  1479. XFollowed by another single quote, returns to the postion at
  1480. Xwhich the last "large" movement command was executed.
  1481. XAll marks are lost when a new file is examined.
  1482. X.PP
  1483. X.IP "^X^X"
  1484. XSame as single quote.
  1485. X.PP
  1486. X.IP /pattern
  1487. XSearch forward in the file for the N-th line containing the pattern.
  1488. XN defaults to 1.
  1489. XThe pattern is a regular expression, as recognized by
  1490. X.I ed.
  1491. XThe search starts at the second line displayed
  1492. X(but see the -a option, which changes this).
  1493. X.PP
  1494. X.IP ?pattern
  1495. XSearch backward in the file for the N-th line containing the pattern.
  1496. XThe search starts at the line immediately before the top line displayed.
  1497. X.PP
  1498. X.IP /!pattern
  1499. XLike /, but the search is for the N-th line
  1500. Xwhich does NOT contain the pattern.
  1501. X.PP
  1502. X.IP ?!pattern
  1503. XLike ?, but the search is for the N-th line
  1504. Xwhich does NOT contain the pattern.
  1505. X.PP
  1506. X.IP n
  1507. XRepeat previous search, for N-th line containing the last pattern
  1508. X(or NOT containing the last pattern, if the previous search
  1509. Xwas /! or ?!).
  1510. X.PP
  1511. X.IP "E [filename]"
  1512. XExamine a new file.
  1513. XIf the filename is missing, the "current" file (see the N and P commands
  1514. Xbelow) from the list of files in the command line is re-examined.
  1515. XIf the filename is a pound sign (#), the previously examined file is
  1516. Xre-examined.
  1517. X.PP
  1518. X.IP "^X^V or :e"
  1519. XSame as E.
  1520. XWarning: some systems use ^V as a special literalization character.
  1521. X.PP
  1522. X.IP "N or :n"
  1523. XExamine the next file (from the list of files given in the command line).
  1524. XIf a number N is specified (not to be confused with the command N),
  1525. Xthe N-th next file is examined.
  1526. X.PP
  1527. X.IP "P or :p"
  1528. XExamine the previous file.
  1529. XIf a number N is specified, the N-th previous file is examined.
  1530. X.PP
  1531. X.IP "= or ^G"
  1532. XPrints some information about the file being viewed,
  1533. Xincluding its name
  1534. Xand the line number and byte offset of the bottom line being displayed.
  1535. XIf possible, it also prints the length of the file
  1536. Xand the percent of the file above the last displayed line.
  1537. X.PP
  1538. X.IP \-
  1539. XFollowed by one of the command line option letters (see below),
  1540. Xthis will change the setting of that option
  1541. Xand print a message describing the new setting.
  1542. XIf the option letter has a numeric value (such as -b or -h),
  1543. Xor a string value (such as -P or -t),
  1544. Xa new value may be entered after the option letter.
  1545. X.PP
  1546. X.IP \_
  1547. X(Underscore.)
  1548. XFollowed by one of the command line option letters (see below),
  1549. Xthis will print a message describing the current setting of that option.
  1550. XThe setting of the option is not changed.
  1551. X.PP
  1552. X.IP +cmd
  1553. XCauses the specified cmd to be executed each time a new file is examined.
  1554. XFor example, +G causes 
  1555. X.I less
  1556. Xto initially display each file starting at the end 
  1557. Xrather than the beginning.
  1558. X.PP
  1559. X.IP V
  1560. XPrints the version number of 
  1561. X.I less 
  1562. Xbeing run.
  1563. X.PP
  1564. X.IP "q or :q or ZZ"
  1565. XExits
  1566. X.I less.
  1567. X.PP
  1568. XThe following 
  1569. Xtwo 
  1570. Xcommands may or may not be valid, depending on your particular installation.
  1571. X.PP
  1572. X.IP v
  1573. XInvokes an editor to edit the current file being viewed.
  1574. XThe editor is taken from the environment variable EDITOR,
  1575. Xor defaults to "vi".
  1576. X.PP
  1577. X.IP "! shell-command"
  1578. XInvokes a shell to run the shell-command given.
  1579. XA percent sign in the command is replaced by the name of the
  1580. Xcurrent file.  "!!" repeats the last shell command.
  1581. X"!" with no shell command simply invokes a shell.
  1582. XIn all cases, the shell is taken from the environment variable SHELL,
  1583. Xor defaults to "sh".
  1584. X.PP
  1585. X.SH OPTIONS
  1586. XCommand line options are described below.
  1587. XMost options may be changed while
  1588. X.I less 
  1589. Xis running, via the "\-" command.
  1590. X.PP
  1591. XOptions are also taken from the environment variable "LESS".
  1592. XFor example, 
  1593. Xto avoid typing "less -options ..." each time 
  1594. X.I less 
  1595. Xis invoked, you might tell 
  1596. X.I csh:
  1597. X.sp
  1598. Xsetenv LESS "-options"
  1599. X.sp
  1600. Xor if you use 
  1601. X.I sh:
  1602. X.sp
  1603. XLESS="-options"; export LESS
  1604. X.sp
  1605. XThe environment variable is parsed before the command line,
  1606. Xso command line options override the LESS environment variable.
  1607. XIf an option appears in the LESS variable, it can be reset
  1608. Xto its default on the command line by beginning the command
  1609. Xline option with "-+".
  1610. X.sp
  1611. XA dollar sign ($) may be used to signal the end of an option string.
  1612. XThis is important only for options like -P which take a
  1613. Xfollowing string.
  1614. X.IP -a
  1615. XNormally, forward searches start just after
  1616. Xthe top displayed line (that is, at the second displayed line).
  1617. XThus, forward searches include the currently displayed screen.
  1618. XThe -a option causes forward searches to start 
  1619. Xjust after the bottom line displayed,
  1620. Xthus skipping the currently displayed screen.
  1621. X.IP -A
  1622. XThe -A option causes searches to start at the second SCREEN line
  1623. Xdisplayed, as opposed to the default which is to start at the second
  1624. XREAL line displayed.
  1625. XFor example, suppose a long real line occupies the first three screen lines.
  1626. XThe default search will start at the second real line (the fourth
  1627. Xscreen line), while the -A option
  1628. Xwill cause the search to start at the second screen line (in the
  1629. Xmidst of the first real line).
  1630. X(This option is rarely useful.)
  1631. X.IP -b
  1632. XThe -b\fIn\fR option tells
  1633. X.I less
  1634. Xto use a non-standard number of buffers.
  1635. XBuffers are 1K, and normally 10 buffers are used
  1636. X(except if data in coming from standard input; see the -B option).
  1637. XThe number \fIn\fR specifies a different number of buffers to use.
  1638. X.IP -B
  1639. XNormally, when data is coming from standard input,
  1640. Xbuffers are allocated automatically as needed, to avoid loss of data.
  1641. XThe -B option disables this feature, so that only the default number
  1642. Xof buffers are used.
  1643. XIf more data is read than will fit in the buffers, the oldest
  1644. Xdata is discarded.
  1645. X.IP -c
  1646. XNormally, 
  1647. X.I less 
  1648. Xwill repaint the screen by scrolling from the bottom of the screen.
  1649. XIf the -c option is set, when
  1650. X.I less 
  1651. Xneeds to change the entire display, it will paint from the top line down.
  1652. X.IP -C
  1653. XThe -C option is like -c, but the screen is cleared before it is repainted.
  1654. X.IP -d
  1655. XNormally,
  1656. X.I less
  1657. Xwill complain if the terminal is dumb; that is, lacks some important capability,
  1658. Xsuch as the ability to clear the screen or scroll backwards.
  1659. XThe -d option suppresses this complaint 
  1660. X(but does not otherwise change the behavior of the program on a dumb terminal).
  1661. X.IP -e
  1662. XNormally the only way to exit less is via the "q" command.
  1663. XThe -e option tells less to automatically exit
  1664. Xthe second time it reaches end-of-file.
  1665. X.IP -E
  1666. XThe -E flag causes less to exit the first time it reaches end-of-file.
  1667. X.IP -h
  1668. XNormally,
  1669. X.I less
  1670. Xwill scroll backwards when backwards movement is necessary.
  1671. XThe -h option specifies a maximum number of lines to scroll backwards.
  1672. XIf it is necessary to move backwards more than this many lines,
  1673. Xthe screen is repainted in a forward direction.
  1674. X(If the terminal does not have the ability to scroll
  1675. Xbackwards, -h0 is implied.)
  1676. X.IP -i
  1677. XThe -i option causes searches to ignore case; that is,
  1678. Xuppercase and lowercase are considered identical.
  1679. XAlso, text which is overstruck or underlined can be searched for.
  1680. X.IP -l
  1681. XThe -l option, followed immediately by a filename,
  1682. Xwill cause 
  1683. X.I less
  1684. Xto copy its input to the named file as it is being viewed.
  1685. XThis applies only when the input file is a pipe,
  1686. Xnot an ordinary file.
  1687. XIf the file already exists, less will ask for confirmation before
  1688. Xoverwriting it.
  1689. X.IP -L
  1690. XThe -L option is like -l, but it will overwrite an existing
  1691. Xfile without asking for confirmation.
  1692. X.sp
  1693. XIf no log file has been specified,
  1694. Xthe -l and -L options can be used from within less to specify a log file.
  1695. XWithout a file name, they will simply report the name of the log file.
  1696. X.IP -m
  1697. XNormally,
  1698. X.I less
  1699. Xprompts with a colon.
  1700. XThe -m option causes 
  1701. X.I less
  1702. Xto prompt verbosely (like 
  1703. X.I more),
  1704. Xwith the percent into the file.
  1705. X.IP -M
  1706. XThe -M option causes 
  1707. X.I less
  1708. Xto prompt even more verbosely than 
  1709. X.I more.
  1710. X.IP -n
  1711. XThe -n flag suppresses line numbers.
  1712. XThe default (to use line numbers) may cause
  1713. X.I less
  1714. Xto run more slowly in some cases, especially with a very large input file.
  1715. XSuppressing line numbers with the -n flag will avoid this problem.
  1716. XUsing line numbers means: the line number will be displayed in the verbose
  1717. Xprompt and in the = command,
  1718. Xand the v command will pass the current line number to the editor.
  1719. X.IP -P
  1720. XThe -P option provides a way to tailor the three prompt
  1721. Xstyles to your own preference.
  1722. XYou would normally put this option in your LESS environment
  1723. Xvariable, rather than type it in with each less command.
  1724. XSuch an option must either be the last option in the LESS variable,
  1725. Xor be terminated by a dollar sign.
  1726. X-P followed by a string changes the default (short) prompt to that string.
  1727. X-Pm changes the medium (-m) prompt to the string, and
  1728. X-PM changes the long (-M) prompt.
  1729. XAlso, -P= changes the message printed by the = command to the given string.
  1730. XAll prompt strings consist of a sequence of 
  1731. Xletters and special escape sequences.
  1732. XSee the section on PROMPTS for more details.
  1733. X.IP -q
  1734. XNormally, if an attempt is made to scroll past the end of the file
  1735. Xor before the beginning of the file, the terminal bell is rung to
  1736. Xindicate this fact.
  1737. XThe -q option tells
  1738. X.I less
  1739. Xnot to ring the bell at such times.
  1740. XIf the terminal has a "visual bell", it is used instead.
  1741. X.IP -Q
  1742. XEven if -q is given, 
  1743. X.I less 
  1744. Xwill ring the bell on certain other errors,
  1745. Xsuch as typing an invalid character.
  1746. XThe -Q option tells
  1747. X.I less
  1748. Xto be quiet all the time; that is, never ring the terminal bell.
  1749. XIf the terminal has a "visual bell", it is used instead.
  1750. X.IP -s
  1751. XThe -s option causes
  1752. Xconsecutive blank lines to be squeezed into a single blank line.
  1753. XThis is useful when viewing
  1754. X.I nroff
  1755. Xoutput.
  1756. X.IP -t
  1757. XThe -t option, followed immediately by a TAG,
  1758. Xwill edit the file containing that tag.
  1759. XFor this to work, there must be a file called "tags" in the
  1760. Xcurrent directory, which was previously built by the 
  1761. X.I ctags
  1762. X(1) command.
  1763. XThis option may also be specified from within less 
  1764. X(using the \- command) as a way of examining a new file.
  1765. X.IP -u
  1766. XIf the -u option is given, 
  1767. Xbackspaces are treated as printable characters;
  1768. Xthat is, they are sent to the terminal when they appear in the input.
  1769. X.IP -U
  1770. XIf the -U option is given,
  1771. Xbackspaces are printed as the two character sequence "^H".
  1772. X.sp
  1773. XIf neither -u nor -U is given,
  1774. Xbackspaces which appear adjacent to an underscore character
  1775. Xare treated specially:
  1776. Xthe underlined text is displayed 
  1777. Xusing the terminal's hardware underlining capability.
  1778. XAlso, backspaces which appear between two identical characters
  1779. Xare treated specially: 
  1780. Xthe overstruck text is printed 
  1781. Xusing the terminal's hardware boldface capability.
  1782. XOther backspaces are deleted, along with the preceeding character.
  1783. X.IP -w
  1784. XNormally,
  1785. X.I less
  1786. Xuses a tilde character to represent lines past the end of the file.
  1787. XThe -w option causes blank lines to be used instead.
  1788. X.IP -x
  1789. XThe -x\fIn\fR option sets tab stops every \fIn\fR positions.
  1790. XThe default for \fIn\fR is 8.
  1791. X.IP -[z]
  1792. XWhen given a backwards or forwards window command,
  1793. X.I less
  1794. Xwill by
  1795. Xdefault scroll backwards or forwards one screenful of lines. 
  1796. XThe -z\fIn\fR option changes the default scrolling window size 
  1797. Xto \fIn\fR lines.
  1798. XNote that the "z" is optional for compatibility with
  1799. X.I more.
  1800. X.IP +
  1801. XIf a command line option begins with \fB+\fR,
  1802. Xthe remainder of that option is taken to be an initial command to
  1803. X.I less.
  1804. XFor example, +G tells
  1805. X.I less
  1806. Xto start at the end of the file rather than the beginning,
  1807. Xand +/xyz tells it to start at the first occurence of "xyz" in the file.
  1808. XAs a special case, +<number> acts like +<number>g; 
  1809. Xthat is, it starts the display at the specified line number
  1810. X(however, see the caveat under the "g" command above).
  1811. XIf the option starts with \fB++\fR, the initial command applies to
  1812. Xevery file being viewed, not just the first one.
  1813. XThe + command described previously
  1814. Xmay also be used to set (or change) an initial command for every file.
  1815. X
  1816. X.SH "KEY BINDINGS"
  1817. XYou may define your own less commands by using the program 
  1818. X.I lesskey
  1819. X(1)
  1820. Xto create a file called ".less" in your home directory.
  1821. XThis file specifies a set of command keys and an action
  1822. Xassociated with each key.
  1823. XSee the
  1824. X.I lesskey
  1825. Xmanual page for more details.
  1826. X
  1827. X.SH "PROMPTS"
  1828. XThe -P option allows you to tailor the prompt to your preference.
  1829. XThe string given to the -P option replaces the specified prompt string.
  1830. XCertain characters in the string are interpreted specially.
  1831. XThe prompt mechanism is rather complicated to provide flexibility,
  1832. Xbut the ordinary user need not understand the details of constructing
  1833. Xpersonalized prompt strings.
  1834. X.sp
  1835. XA percent sign followed by a single character is expanded
  1836. Xaccording to what the following character is:
  1837. X.IP "%bX"
  1838. XReplaced by the byte offset into the current input file.
  1839. XThe b is followed by a single character (shown as X above)
  1840. Xwhich specifies the line whose byte offset is to be used.
  1841. XIf the character is a "t", the byte offset of the top line in the
  1842. Xdisplay is used,
  1843. Xan "m" means use the middle line,
  1844. Xa "b" means use the bottom line,
  1845. Xand a "B" means use the line just after the bottom line.
  1846. X.IP "%f"
  1847. XReplaced by the name of the current input file.
  1848. X.IP "%i"
  1849. XReplaced by the index of the current file in the list of
  1850. Xinput files.
  1851. X.IP "%lX"
  1852. XReplaced by the line number of a line in the input file.
  1853. XThe line to be used is determined by the X, as with the %b option.
  1854. X.IP "%m"
  1855. XReplaced by the total number of input files.
  1856. X.IP "%pX"
  1857. XReplaced by the percent into the current input file.
  1858. XThe line used is determined by the X as with the %b option.
  1859. X.IP "%s"
  1860. XReplaced by the size of the current input file.
  1861. X.IP "%t"
  1862. XCauses any trailing spaces to be removed.
  1863. XUsually used at the end of the string, but may appear anywhere.
  1864. X.IP "%x"
  1865. XReplaced by the name of the next input file in the list.
  1866. X.PP
  1867. XIf any item is unknown (for example, the file size if input
  1868. Xis a pipe), a question mark is printed instead.
  1869. X.PP
  1870. XThe format of the prompt string can be changed
  1871. Xdepending on certain conditions.
  1872. XA question mark followed by a single character acts like an "IF":
  1873. Xdepending on the following character, a condition is evaluated.
  1874. XIf the condition is true, any characters following the question mark
  1875. Xand condition character, up to a period, are included in the prompt.
  1876. XIf the condition is false, such characters are not included.
  1877. XA colon appearing between the question mark and the
  1878. Xperiod can be used to establish an "ELSE": any characters between
  1879. Xthe colon and the period are included in the string if and only if
  1880. Xthe IF condition is false.
  1881. XCondition characters (which follow a question mark) may be:
  1882. X.IP "?a"
  1883. XTrue if any characters have been included in the prompt so far.
  1884. X.IP "?bX"
  1885. XTrue if the byte offset of the specified line is known.
  1886. X.IP "?e"
  1887. XTrue if at end-of-file.
  1888. X.IP "?f"
  1889. XTrue if there is an input filename
  1890. X(that is, if input is not a pipe).
  1891. X.IP "?lX"
  1892. XTrue if the line number of the specified line is known.
  1893. X.IP "?m"
  1894. XTrue if there is more than one input file.
  1895. X.IP "?n"
  1896. XTrue if this is the first prompt in a new input file.
  1897. X.IP "?pX"
  1898. XTrue if the percent into the current input file
  1899. Xof the specified line is known.
  1900. X.IP "?s"
  1901. XTrue if the size of current input file is known.
  1902. X.IP "?x"
  1903. XTrue if there is a next input file
  1904. X(that is, if the current input file is not the last one).
  1905. X.PP
  1906. XAny characters other than the special ones
  1907. X(question mark, colon, period, percent, and backslash)
  1908. Xbecome literally part of the prompt.
  1909. XAny of the special characters may be included in the prompt literally
  1910. Xby preceeding it with a backslash.
  1911. X.PP
  1912. XSome examples:
  1913. X.sp
  1914. X?f%f:Standard input.
  1915. X.sp
  1916. XThis prompt prints the filename, if known;
  1917. Xotherwise the string "Standard input".
  1918. X.sp
  1919. X?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-...
  1920. X.sp
  1921. XThis prompt would print the filename, if known.
  1922. XThe filename is followed by the line number, if known,
  1923. Xotherwise the percent if known, otherwise the byte offset if known.
  1924. XOtherwise, a dash is printed.
  1925. XNotice how each question mark has a matching period,
  1926. Xand how the % after the %pt
  1927. Xis included literally by escaping it with a backslash.
  1928. X.sp
  1929. X?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x..%t
  1930. X.sp
  1931. XThis prints the filename if this is the first prompt in a file,
  1932. Xfollowed by the "file N of N" message if there is more
  1933. Xthan one input file.
  1934. XThen, if we are at end-of-file, the string "(END)" is printed
  1935. Xfollowed by the name of the next file, if there is one.
  1936. XFinally, any trailing spaces are truncated.
  1937. XThis is the default prompt.
  1938. XFor reference, here are the defaults for
  1939. Xthe other two prompts (-m and -M respectively).
  1940. XEach is broken into two lines here for readability only.
  1941. X.nf
  1942. X.sp
  1943. X?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x.:
  1944. X    ?pB%pB\\%:byte\ %bB?s/%s...%t
  1945. X.sp
  1946. X?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltline\ %lt\ :byte\ %bB?s/%s\ ..
  1947. X    ?e(END)\ ?x-\ Next\\:\ %x.:?pB%pB\\%..%t
  1948. X.sp
  1949. X.fi
  1950. XAnd here is the default message produced by the = command:
  1951. X.nf
  1952. X.sp
  1953. X?f%f\ .?m(file\ %i\ of\ %m)\ .?ltline\ %lt\ .
  1954. X    byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\\%..%t
  1955. X.fi
  1956. X
  1957. X.SH "SEE ALSO"
  1958. Xlesskey(1)
  1959. X
  1960. X.SH WARNINGS
  1961. XThe = command and prompts (unless changed by -P)
  1962. Xreport the line number of the line at the top of the screen,
  1963. Xbut the byte and percent of the line at the bottom of the screen.
  1964. END_OF_FILE
  1965. echo shar: Extracting \"lesskey.nro\"
  1966. sed "s/^X//" >'lesskey.nro' <<'END_OF_FILE'
  1967. X.TH LESSKEY 1
  1968. X.SH NAME
  1969. Xlesskey \- specify key bindings for less
  1970. X.SH SYNOPSIS
  1971. X.B "lesskey [-o output] [input]"
  1972. X.SH DESCRIPTION
  1973. X.I Lesskey
  1974. Xis used to specify a set of key bindings to be used by 
  1975. X.I less.
  1976. XThe input file is a text file which describes the key bindings,
  1977. Xand the output file is a binary file which is used by 
  1978. X.I less.
  1979. XIf no input file is specified, standard input is used.
  1980. XIf no output file is specified, $HOME/.less is used.
  1981. X.PP
  1982. XThe input file consists of lines of the form:
  1983. X.sp
  1984. X    string <whitespace> action <newline>
  1985. X.sp
  1986. XWhitespace is any sequence of one or more spaces and/or tabs.
  1987. XThe "string" is the command key(s) which invoke the action.
  1988. XThe string may be a single command key, or a sequence of up to 15 keys.
  1989. XThe "action" is the name of the less action, from the list below.
  1990. XThe characters in the "string" may appear literally, or be
  1991. Xprefixed by a carat to indicate a control key.
  1992. XA backslash may be used to cause the following character
  1993. Xto be taken literally.
  1994. XCharacters which must be preceeded by backslash include
  1995. Xcarat, space, tab and the backslash itself.
  1996. XA backslash followed by one to three octal digits may be used to
  1997. Xspecify a character by its octal value.
  1998. XBlank lines and lines which start with a pound sign (#) are ignored.
  1999. X.PP
  2000. XAs an example, the following input file describes the set of
  2001. Xdefault command keys used by less:
  2002. X.sp
  2003. X.nf
  2004. X    k            back-line
  2005. X    y            back-line
  2006. X    ^K            back-line
  2007. X    ^Y            back-line
  2008. X    ^P            back-line
  2009. X    b            back-screen
  2010. X    ^B            back-screen
  2011. X    \\33v            back-screen
  2012. X    u            back-scroll
  2013. X    ^U            back-scroll
  2014. X    ?            back-search
  2015. X    E            examine
  2016. X    ^X^V            examine
  2017. X    +            first-cmd
  2018. X    e            forw-line
  2019. X    j            forw-line
  2020. X    ^E            forw-line
  2021. X    ^J            forw-line
  2022. X    ^M            forw-line
  2023. X    ^N            forw-line
  2024. X    f            forw-screen
  2025. X    ^F            forw-screen
  2026. X    \\40            forw-screen
  2027. X    ^V            forw-screen
  2028. X    d            forw-scroll
  2029. X    ^D            forw-scroll
  2030. X    /            forw-search
  2031. X    G            goto-end
  2032. X    >            goto-end
  2033. X    \\33>            goto-end
  2034. X    g            goto-line
  2035. X    <            goto-line
  2036. X    \\33<            goto-line
  2037. X    '            goto-mark
  2038. X    ^X^X            goto-mark
  2039. X    H            help
  2040. X    N            next-file
  2041. X    %            percent
  2042. X    p            percent
  2043. X    P            prev-file
  2044. X    q            quit
  2045. X    ZZ            quit
  2046. X    ^L            repaint
  2047. X    ^R            repaint
  2048. X    r            repaint
  2049. X    R            flush-repaint
  2050. X    n            repeat-search
  2051. X    m            set-mark
  2052. X    !            shell
  2053. X    =            status
  2054. X    ^G            status
  2055. X    -            toggle-option
  2056. X    _            display-option
  2057. X    V            version
  2058. X    v            visual
  2059. X.fi
  2060. X.sp
  2061. XCommands specified by
  2062. X.I lesskey
  2063. Xtake precedence over the default commands.
  2064. XA default command key may be disabled by including it in the
  2065. Xkey file with the action "invalid".
  2066. X
  2067. X.SH "SEE ALSO"
  2068. Xless(1)
  2069. END_OF_FILE
  2070. echo shar: Extracting \"lesskey.man\"
  2071. sed "s/^X//" >'lesskey.man' <<'END_OF_FILE'
  2072. X
  2073. X
  2074. X
  2075. X     LLLLEEEESSSSSSSSKKKKEEEEYYYY((((1111))))                  UUUUNNNNIIIIXXXX 5555....0000                   LLLLEEEESSSSSSSSKKKKEEEEYYYY((((1111))))
  2076. X
  2077. X
  2078. X
  2079. X     NNNNAAAAMMMMEEEE
  2080. X          lesskey - specify key bindings for less
  2081. X
  2082. X     SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  2083. X          lllleeeesssssssskkkkeeeeyyyy [[[[----oooo oooouuuuttttppppuuuutttt]]]] [[[[iiiinnnnppppuuuutttt]]]]
  2084. X
  2085. X     DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  2086. X          _L_e_s_s_k_e_y is used to specify a set of key bindings to be used
  2087. X          by _l_e_s_s. The input file is a text file which describes the
  2088. X          key bindings, and the output file is a binary file which is
  2089. X          used by _l_e_s_s. If no input file is specified, standard input
  2090. X          is used.  If no output file is specified, $HOME/.less is
  2091. X          used.
  2092. X
  2093. X          The input file consists of lines of the form:
  2094. X
  2095. X               string <whitespace> action <newline>
  2096. X
  2097. X          Whitespace is any sequence of one or more spaces and/or
  2098. X          tabs.  The "string" is the command key(s) which invoke the
  2099. X          action.  The string may be a single command key, or a
  2100. X          sequence of up to 15 keys.  The "action" is the name of the
  2101. X          less action, from the list below.  The characters in the
  2102. X          "string" may appear literally, or be prefixed by a carat to
  2103. X          indicate a control key.  A backslash may be used to cause
  2104. X          the following character to be taken literally.  Characters
  2105. X          which must be preceeded by backslash include carat, space,
  2106. X          tab and the backslash itself.  A backslash followed by one
  2107. X          to three octal digits may be used to specify a character by
  2108. X          its octal value.  Blank lines and lines which start with a
  2109. X          pound sign (#) are ignored.
  2110. X
  2111. X          As an example, the following input file describes the set of
  2112. X          default command keys used by less:
  2113. X
  2114. X               k              back-line
  2115. X               y              back-line
  2116. X               ^K             back-line
  2117. X               ^Y             back-line
  2118. X               ^P             back-line
  2119. X               b              back-screen
  2120. X               ^B             back-screen
  2121. X               \33v           back-screen
  2122. X               u              back-scroll
  2123. X               ^U             back-scroll
  2124. X               ?              back-search
  2125. X               E              examine
  2126. X               ^X^V           examine
  2127. X               +              first-cmd
  2128. X               e              forw-line
  2129. X               j              forw-line
  2130. X               ^E             forw-line
  2131. X
  2132. X
  2133. X
  2134. X     Page 1                                          (printed 7/19/88)
  2135. X
  2136. X
  2137. X
  2138. X
  2139. X
  2140. X
  2141. X     LLLLEEEESSSSSSSSKKKKEEEEYYYY((((1111))))                  UUUUNNNNIIIIXXXX 5555....0000                   LLLLEEEESSSSSSSSKKKKEEEEYYYY((((1111))))
  2142. X
  2143. X
  2144. X
  2145. X               ^J             forw-line
  2146. X               ^M             forw-line
  2147. X               ^N             forw-line
  2148. X               f              forw-screen
  2149. X               ^F             forw-screen
  2150. X               \40            forw-screen
  2151. X               ^V             forw-screen
  2152. X               d              forw-scroll
  2153. X               ^D             forw-scroll
  2154. X               /              forw-search
  2155. X               G              goto-end
  2156. X               >              goto-end
  2157. X               \33>           goto-end
  2158. X               g              goto-line
  2159. X               <              goto-line
  2160. X               \33<           goto-line
  2161. X               '              goto-mark
  2162. X               ^X^X           goto-mark
  2163. X               H              help
  2164. X               N              next-file
  2165. X               %              percent
  2166. X               p              percent
  2167. X               P              prev-file
  2168. X               q              quit
  2169. X               ZZ             quit
  2170. X               ^L             repaint
  2171. X               ^R             repaint
  2172. X               r              repaint
  2173. X               R              flush-repaint
  2174. X               n              repeat-search
  2175. X               m              set-mark
  2176. X               !              shell
  2177. X               =              status
  2178. X               ^G             status
  2179. X               -              toggle-option
  2180. X               _              display-option
  2181. X               V              version
  2182. X               v              visual
  2183. X
  2184. X          Commands specified by _l_e_s_s_k_e_y take precedence over the
  2185. X          default commands.  A default command key may be disabled by
  2186. X          including it in the key file with the action "invalid".
  2187. X
  2188. X
  2189. X     SSSSEEEEEEEE AAAALLLLSSSSOOOO
  2190. X          less(1)
  2191. X
  2192. X
  2193. X
  2194. X
  2195. X
  2196. X
  2197. X
  2198. X
  2199. X
  2200. X     Page 2                                          (printed 7/19/88)
  2201. X
  2202. X
  2203. X
  2204. END_OF_FILE
  2205.  
  2206.  
  2207.